package com.zp.soft2.ktvvod;

import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class KtvSond {
    private static ArrayList<String> list = new ArrayList();
    private static Scanner scanner = new Scanner(System.in);


    public static void addMusic(){
        System.out.println("请输入歌曲名");
        String MusicName = scanner.next();
        list.add(MusicName);
        System.out.println("已添加歌曲"+MusicName);
    }
    public static void addTop(){
        System.out.println("请输入歌曲名");
        String MusicName = scanner.next();
        int musicIndex = list.indexOf(MusicName);

        if (musicIndex ==0 ){
            System.out.println("当前歌曲已置顶");
        }else if (musicIndex <0){
            System.out.println("当前歌曲列表没有此歌曲");
        }else {
            list.remove(MusicName);
            list.add(0,MusicName);
            System.out.println("歌曲"+MusicName+"已置顶");
        }
    }
    public static void addBefore(){
        System.out.println("请输入要置前的歌曲名称");
        String MusicName = scanner.next();
        int musicIndex = list.indexOf(MusicName);

        if (musicIndex ==0 ){
            System.out.println("当前歌曲已为第一首");
        }else if (musicIndex <0){
            System.out.println("当前歌曲列表没有此歌曲");
        }else {
            list.remove(MusicName);
            list.add(musicIndex - 1 ,MusicName);
            System.out.println("歌曲"+MusicName+"已置前");
        }



    }
    public static void Music (){
        System.out.println("当前歌曲库为：");
        System.out.println(list);
    }
    public static void MusicDelete (){
        System.out.println("请输入要删除的歌曲名称");
        String MusicName = scanner.next();
        int musicIndex = list.indexOf(MusicName);
        if (musicIndex <0){
            System.out.println("当前歌曲列表没有此歌曲");
        }else {
            list.remove(MusicName);
            System.out.println("你已删除歌曲"+MusicName);
        }
    }
}
